const AdminBiz = require('../../../../store/admin_biz_config.js');
const projectSetting = require('../../../../../../config/projects_config.js');
const pathResolver = require('../config/path_resolver');
const pathImport = require('../helpers/path_import.js');
const { pageHelper } = pathImport;
const { createStoreBindings } = require('mobx-miniprogram-bindings');
const { adminStore } = require('../../../../config/store_config.js');

Page({

	/**
	 * 页面的初始数据
	 */
	data: {

	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {
		if (!AdminBiz.isAdmin(this)) return;

		// 创建MobX绑定
		this.storeBindings = createStoreBindings(this, {
			store: adminStore,
			fields: ['setupContentItems'],
			actions: ['setSetupContentItems']
		});

		// 如果adminStore中没有设置内容项，则从projectSetting中获取
		if (!adminStore.setupContentItems || adminStore.setupContentItems.length === 0) {
			this.setSetupContentItems(projectSetting.SETUP_CONTENT_ITEMS);
		}
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {
		// 销毁MobX绑定
		this.storeBindings && this.storeBindings.destroyStoreBindings();
	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {

	},

	url: function (e) {
		pageHelper.url(e, this);
	}
})